package com.tronapi.c.model.request;

import com.tronapi.c.model.Signature;

import java.io.IOException;
import java.util.HashMap;

public class RegisterRequest {

    private String deviceId;

    private Long timestamp;

    private String version;

    private String appName;

    private String sign;

    public boolean checkSign() throws IOException {
        HashMap<String, String> tMap = new HashMap<>();
        tMap.put("deviceId", deviceId);
        tMap.put("version", version);
        tMap.put("appName", appName);
        tMap.put("timestamp", String.valueOf(timestamp));
        String pSign = Signature.getSignature(tMap);
        return pSign.equalsIgnoreCase(sign);
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }
}
